#include <iostream>

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
const LL P = 5000011;

LL f[N], g[N];

int n, k;

LL qpow(LL a, LL b, LL p)
{
	LL ret = 1;
	while(b)
	{
		if(b & 1) ret = ret * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ret;
}

void init()
{
	f[0] = 1;
	for(int i = 1; i <= n; i++) f[i] = f[i - 1] * i % P;
	g[n] = qpow(f[n], P - 2, P);
	for(int i = n - 1; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % P;
}

LL C(int n, int m, LL p)
{
	if(n < m) return 0;
	return f[n] * g[m] % P * g[n - m] % p;
}

int main()
{
	cin >> n >> k;
	init();
	LL ans = 1;
	for(int i = 1; i <= n / k; i++)
	{
		ans += C(n - (i - 1) * k, i, P);
		ans %= P;
	}
	cout << ans << endl;
	return 0;
}



